package com.xiaotou.db.pojo;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;

import org.apache.commons.lang.math.NumberUtils;

import weibo4j.User;

@Entity
@DiscriminatorValue("sina")
public class SinaUser extends WbUser {

	private static final long serialVersionUID = 2053146213727597747L;

	public SinaUser() {
		super();
	}

	public SinaUser bindFromUser(User user) {
		this.setWbId(user.getId());
		this.setScreenName(user.getScreenName());
		this.setName(user.getName());
		this.setGender(user.getGender());
		this.setFollowsCount(user.getFollowersCount());
		this.setFriendsCount(user.getFriendsCount());
		this.setStatusCount(user.getStatusesCount());
		this.setLocation(user.getLocation());
		this.setProfileImageUrl(user.getProfileImageUrl());
		if (user.isVerified()) {
			this.setVerified(WbUser.ISTRUE);
		}
		if (NumberUtils.isNumber(user.getProvince())) {
			this.setProvince(Integer.valueOf(user.getProvince()));
		}

		if (NumberUtils.isNumber(user.getCity())) {
			this.setCity(Integer.valueOf(user.getCity()));
		}
		return this;
	}
}
